listbox: check gsequence end iter in get_row_at_index
authorPaolo Borelli <pborelli@gnome.org>
Sun, 4 May 2014 17:38:31 +0000 (19:38 +0200)
committerPaolo Borelli <pborelli@gnome.org>
Sun, 4 May 2014 17:45:28 +0000 (19:45 +0200)
gtk/gtklistbox.c

index b6d0fe2584463c3a59b24d246e25067797ffd6b4..62aefe58683def07597dc901545e1f810a40929f 100644 (file)
@@ -577,8 +577,10 @@ gtk_list_box_get_selected_row (GtkListBox *box)
  * @index_: the index of the row
  *
  * Gets the n-th child in the list (not counting headers).
+ * If @_index is negative or larger than the number of items in the
+ * list, %NULL is returned.
  *
- * Returns: (transfer none): the child #GtkWidget
+ * Returns: (transfer none): the child #GtkWidget or %NULL
  *
  * Since: 3.10
  */
@@ -591,7 +593,7 @@ gtk_list_box_get_row_at_index (GtkListBox *box,
   g_return_val_if_fail (GTK_IS_LIST_BOX (box), NULL);
 
   iter = g_sequence_get_iter_at_pos (BOX_PRIV (box)->children, index_);
-  if (iter)
+  if (!g_sequence_iter_is_end (iter))
     return g_sequence_get (iter);
 
   return NULL;